#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Student{
    char *name;
    int age;
};

void test(struct Student *p){
    p->name=(char*)malloc(strlen(p->name)+1);
    strcpy(p->name,"a");
    p->age=10;
    printf("name=%s,age=%d\n",p->name,p->age);
}


int main(){
    char* str="zyh";
    struct Student s;
    s.name=(char*)malloc(strlen(str)+1);
    strcpy(s.name,"zyh");
    s.age=22;
    printf("name=%s,age=%d\n",s.name,s.age);
    test(&s);
    printf("name=%s,age=%d\n",s.name,s.age);
    if(s.name!=NULL){
        free(s.name);
        s.name=NULL;
    }
    return 0;
}